﻿Public Class Form2



    Private Sub Unit1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Unit1.Click
        Dim generator As New Random
        Dim randomValue As Double
        randomValue = generator.Next(1, Convert.ToInt32(Unit1.Maximum - Unit1.Minimum)) + Unit1.Minimum

        Unit1.AccelerateTo(randomValue)
        Label1.Text = "Accel 2: " & randomValue.ToString
    End Sub

    Private Sub Unit1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Unit1.DoubleClick
        Unit1.AccelerateTo(0)
        Label1.Text = "Accel 2: " & "0"
    End Sub

    Private Sub Unit1_GotFocus(sender As Object, e As EventArgs) Handles Unit1.GotFocus
        MessageBox.Show("Got Focus")
    End Sub

    Private Sub Unit1_LostFocus(sender As Object, e As EventArgs) Handles Unit1.LostFocus
        MessageBox.Show("Lost Focus")
    End Sub

   
  

   
  

    Private Sub Unit1_MaximumChanged(ByVal obj As Object, ByVal evt As System.EventArgs) Handles Unit1.MaximumChanged
        NumericUpDown1.Maximum = Unit1.Maximum
    End Sub

    Private Sub Unit1_MinimumChanged(ByVal obj As Object, ByVal evt As System.EventArgs) Handles Unit1.MinimumChanged
        NumericUpDown1.Minimum = Unit1.Minimum
    End Sub

    Private Sub Unit1_RedLined(ByVal obj As Object, ByVal evt As System.EventArgs) Handles Unit1.RedLined
        Unit1.AlertLight = CartersZoo.DisplayUnit.AlertLightStyle.AlertLightBlinking
    End Sub

    Private Sub Unit1_ValueChanged(ByVal obj As Object, ByVal evt As System.EventArgs) Handles Unit1.ValueChanged
        NumericUpDown1.Value = Unit1.Value
        If Unit1.IsRedlined Then

            Unit1.AlertLight = CartersZoo.DisplayUnit.AlertLightStyle.AlertLightBlinking
        Else
            Unit1.AlertLight = CartersZoo.DisplayUnit.AlertLightStyle.AlertLightOff
        End If


    End Sub

   

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub

   
    Private Sub AboutToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim AboutBox As New CartersZoo.DisplayUnit.AboutBox
        AboutBox.ShowDialog(Me)

    End Sub

    
    
    Private Sub CPUUsageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim f As New FormCPU
        f.Show(Me)

    End Sub

    Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If My.Application.OpenForms.Count > 1 Then
            My.Forms.FormCPU.Close()

        End If
    End Sub

    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label2.Text = CartersZoo.DisplayUnit.Unit.Version
        Unit1.Value = NumericUpDown1.Value
    End Sub

    Private Sub Form2_Load(sender As Object, e As System.EventArgs) Handles Me.Load

    End Sub

    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged


        If CheckBox1.Checked = True Then

            Dim generator As New Random
            Dim randomValue As Integer
            randomValue = generator.Next(70, 200)
            Unit1.AccelerateTo(randomValue)
            Timer1.Enabled = True

        Else
            Unit1.AccelerateTo(0)
            Timer1.Enabled = False

        End If
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Dim generator As New Random
        Dim randomValue As Integer
        randomValue = generator.Next(Unit1.Value - 10, Unit1.Value + 10)
        Unit1.AccelerateTo(randomValue)
        If randomValue <= 0 Then
            CheckBox1.Checked = False
        End If
    End Sub

 
End Class